package com.digital.smartgrow.service.datacenter.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.digital.smartgrow.dao.datacenter.WorkExperienceMapper;
import com.digital.smartgrow.dto.datacenter.WorkExperiencePageDTO;
import com.digital.smartgrow.entity.datacenter.WorkExperience;
import com.digital.smartgrow.service.datacenter.WorkExperienceService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 工作经历 服务实现类
 * </p>
 *
 * @author xiewb
 * @since 2022-04-04
 */
@Service
public class WorkExperienceServiceImpl extends ServiceImpl<WorkExperienceMapper, WorkExperience> implements WorkExperienceService {

    @Override
    public Object getListByPage(WorkExperiencePageDTO pageDTO) {
        Page<WorkExperience> page = new Page<>(pageDTO.getPageNum(), pageDTO.getPageSize());
        QueryWrapper<WorkExperience> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(StringUtils.isNotBlank(pageDTO.getEmployer()), "employer", pageDTO.getEmployer());
        queryWrapper.and(StringUtils.isNotBlank(pageDTO.getName()),
                y -> y.like("name", pageDTO.getName()).or()
                        .like("employeeId", pageDTO.getName()));
        return this.page(page, queryWrapper);
    }

    @Override
    public Object getInfo(Integer id) {
        return this.getById(id);
    }
}
